#include "CAudioManager.h"
#include "CAudio.h"

CAudioManager * CAudioManager::m_CAudioManager = NULL;

CAudioManager::CAudioManager()
{
	m_Background = NULL;
}

CAudioManager::~CAudioManager()
{
}

CAudioManager* CAudioManager::getInstance()
{
	if(m_CAudioManager == NULL)
    {
        m_CAudioManager = new CAudioManager();
        return m_CAudioManager;
    }
    else
        return m_CAudioManager;

}

int CAudioManager::Init(HWND wndHandle)
{
	return initDirectSound(wndHandle);
}

void CAudioManager::loadSound()
{
	m_Background   = LoadSound("Background.wav");
	m_BonusRise    = LoadSound("BonusRise.wav");
	m_BrickBreaked = LoadSound("BrickBreaked.wav");
	m_Bump		   = LoadSound("Bump.wav");
	m_Coin		   = LoadSound("Coin.wav");
	m_Death		   = LoadSound("Death.wav");
	m_FireBall	   = LoadSound("FireBall.wav");
	m_GameOver	   = LoadSound("GameOver.wav");
	m_Jump		   = LoadSound("Jump.wav");
	m_Kick		   = LoadSound("Kick.wav");
	m_Life		   = LoadSound("Life.wav");
	m_Mip		   = LoadSound("Mip.wav");
	m_PipeWarp	   = LoadSound("PipeWarp.wav");
	m_PowerUp	   = LoadSound("PowerUp.wav");
	m_StartGame	   = LoadSound("StartGame.wav");
	m_WinStage	   = LoadSound("WinStage.wav");
}

void CAudioManager::playSound(int ID_Music)
{	
	switch(ID_Music)
	{
		case 1:	
			PlaySound(m_Background);
			break;
		case 2:
			PlaySound(m_BonusRise);
			break;
		case 3:
			PlaySound(m_BrickBreaked);
			break;
		case 4:
			PlaySound(m_Bump);
			break;
		case 5:
			PlaySound(m_Coin);
			break;
		case 6:
			PlaySound(m_Death);
			break;
		case 7:
			PlaySound(m_FireBall);
			break;
		case 8:
			PlaySound(m_GameOver);
			break;
		case 9:
			PlaySound(m_Jump);
			break;
		case 10:
			PlaySound(m_Kick);
			break;
		case 11:
			PlaySound(m_Life);
			break;
		case 12:
			PlaySound(m_Mip);
			break;
		case 13:
			PlaySound(m_PipeWarp);
			break;
		case 14:
			PlaySound(m_PowerUp);
			break;
		case 15:
			PlaySound(m_StartGame);
			break;
		case 16:
			PlaySound(m_WinStage);
			break;
	}
}

void CAudioManager::destroy()
{
	delete m_Background;
	delete m_BonusRise;
	delete m_BrickBreaked;
	delete m_Bump;
	delete m_Coin;	
	delete m_Death;	
	delete m_FireBall;
	delete m_GameOver;
	delete m_Jump;
	delete m_Kick;
	delete m_Life;
	delete m_Mip;
	delete m_PipeWarp;
	delete m_PowerUp;
	delete m_StartGame;
	delete m_WinStage;
}